Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Printing Extensions and Drivers /
Chapter 3 - Printer Drivers / The QuickDraw GX ImageWriter II Printer Driver Messages


Initializing the ImageWriter II Environment

QuickDraw GX sends the GXInitialize message when an application creates a job object, just after the application has called the GXNewJob function so that your driver can initialize any storage and establish the values of global variables. The ImageWriter II printer driver performs very simple initialization. Its override of the GXInitialize message, SD_Initialize, allocates a globals world so that the driver can access the QuickDraw GX globals. The SD_Initialize function is shown in Listing 3-4.

Listing 3-4 Initializing the ImageWriter II printer driver

OSErr SD_Initialize (void) 
{

   SpecGlobalsHdl hGlobals;
   OSErr          anErr;
      
   /* create the globals */
   hGlobals = (SpecGlobalsHdl) NewHandleClear(
                                          sizeof(SpecGlobals) );
   anErr = MemError();

   /* save the globals */
   SetMessageHandlerInstance(hGlobals);

   /* branch to exception handler if necessary */
   nrequire( anErr, MNewHandleClear );

   /* no draft table allocated yet */
   (**hGlobals).draftTable = nil;
   
   return(noErr);
   
MNewHandleClear:
   return(anErr);
}
The SD_Initialize function first allocates the QuickDraw GX message globals. Then it initializes the global handle to the draft table to nil because this table, which is used for drawing draft-quality characters on the printing device, is only needed when the ImageWriter II is printing in draft mode.

You almost always override the GXInitialize message for a driver. No matter which imaging system your driver is written for, you need to initialize the QuickDraw GX message globals. Th GXInitialize message is described on page 4-43 in the chapter "Printing Messages."


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help